/**
 * zmn产品模块-产品列表
 * @author tanghongjun
 * @since 2018/10/18
 */
layui.define(['index', 'form', 'table', 'laypage', 'layedit', 'laydate'], function (exports) {
    var $ = layui.$;
    var form = layui.form;
    var layer = layui.layer;
    var table = layui.table;
    var laypage = layui.laypage;
    var layedit = layui.layedit;
    var laydate = layui.laydate;

    laydate.render({elem: "#createTimeRange", range: true, format: 'yyyy/MM/dd'});

    table.init('zmn-table', {
        toolbar: "#zmn-table-tool",
        page: true,
        limit: json.pageSize,
        height: 'full-189'
    });
    laypage.render(zmnPage.laypageOptions(json));

    // 修改排序
    table.on("edit(zmn-table)", function (obj) {
        zmnPage.laySort(obj, "/msg/temp/modifySort.action", obj.data.templateId);
    });

    // 启用/停用（批量）
    table.on("toolbar(zmn-table)", function (obj) {
        var ids = zmnPage.layTabldIds(obj, "templateId");
        if(obj.event == "start" || obj.event == "stop") {
            if (ids.length === 0) {
                return layer.alert("请选择至少一条数据！");
            }
            console.log(ids);
            zmnPage.layStartStopBatch(obj, "/msg/temp/modifyStatus", ids.join(","));
        }
    });

    //对外暴露的接口
    exports('msg_template_list', {});
});